package com.smart.buss.ctrl;

import com.smart.buss.service.BussChannelService;
import com.smart.buss.vo.BussChannel;
import com.smart.primary.common.common.BaseCtrl;
import com.smart.primary.common.util.AjaxResult;
import com.smart.primary.common.util.Util;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/buss/channel")
public class BussChannelController extends BaseCtrl {

	@Autowired
	private BussChannelService bussChannelService;

	@RequestMapping
	public AjaxResult getList(BussChannel entity) throws Exception{
		List<BussChannel> list=bussChannelService.queryListByPage(entity);
		return getResult(entity, list);
	}

	@RequestMapping("list")
	public List<BussChannel> list(BussChannel entity) throws Exception{
		return bussChannelService.queryList(entity);
	}

	@RequestMapping("/save")
	public AjaxResult save(BussChannel entity) throws Exception{
		BussChannel buss=new BussChannel();
		buss.setId(entity.getId());
		if(bussChannelService.queryObject(buss)==null){
			bussChannelService.insert(entity);
			return AjaxResult.saveSuccess();
		}else {
			bussChannelService.update(entity);
			return AjaxResult.updateSuccess();
		}
	}

	@RequestMapping("/del")
	public AjaxResult del(String id) throws Exception{
		bussChannelService.delete(id);
		return AjaxResult.deleteSuccess();
	}
}
